Avoid R package warning in loadSupport() if autoload is disabled#3513
Avoid R package warning in loadSupport() if autoload is disabled#3513cpsievert merged 7 commits intorstudio:mainfrom
loadSupport() if autoload is disabled#3513Conversation
|
@krlmlr Can you provide instructions on how to reproduce the issue? |
|
Create a Shiny app with a package structure (with Do we need a test here? |
3331b00 to
2c9ceee
Compare
|
Minimal code for reproducing bogus warning here: withr::with_dir(tempdir(check = TRUE),{
dir.create("R", showWarnings = FALSE)
# loadSupport documentation suggests adding a blank R/_disable_autoload.R file
# will disable automatic loading of the R/ files
file.create("R/_disable_autoload.R")
# test that code was not loaded by adding a print statement
writeLines(
"print('R/ code was sourced')",
"R/code.R"
)
# loadSupport checks for a NAMESPACE file and/or a DESCRIPTION file to determine
# if the directory contains a package, add NAMESPACE to trigger the check
file.create("NAMESPACE")
# add minimal app.R code
writeLines(
text = "
shiny::shinyApp(
ui = shiny::fluidPage(),
server = function(input, output, session) {}
)
",
con = "app.R"
)
shiny::runApp()
# still triggers warning, despite not actually running the code in question
}) |
2c9ceee to
3cea593
Compare
R/shinyapp.R
Outdated
| if (length(disabled) > 0){ | ||
| return(invisible(renv)) | ||
| } |
There was a problem hiding this comment.
@krlmlr maybe simpler to move this early exit on disabled to L356 instead of extending the if clause?
There was a problem hiding this comment.
I'm working on a change like that... will push back to this PR in a minute.
There was a problem hiding this comment.
In the end, I think the warning was happening too early. By moving it down we can instead warn just before evaluating the code in the R/ support directory.
loadSupport() if autoload is disabled
krlmlr
left a comment
There was a problem hiding this comment.
Nice, thanks for picking this up!
Co-authored-by: Garrick Aden-Buie <[email protected]>
in
loadSupport(), if_disable_autoload.Rexists.